{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!
Generated Python typestubs for Thrift types
}}
{{> common/auto_generated_py}}

import typing as _typing
import builtins


{{#program:unions?}}
import enum

{{/program:unions?}}
import folly.iobuf as _fbthrift_iobuf
{{#program:enable_abstract_types?}}
import {{program:module_path}}.thrift_abstract_types as _fbthrift_python_abstract_types
{{/program:enable_abstract_types?}}
import {{program:base_library_package}}.types as _fbthrift_python_types
{{#program:generate_immutable_types}}
import {{program:base_library_package}}.exceptions as _fbthrift_python_exceptions
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
import {{program:base_library_package}}.mutable_types as _fbthrift_python_mutable_types
import {{program:base_library_package}}.mutable_exceptions as _fbthrift_python_mutable_exceptions
import {{program:base_library_package}}.mutable_containers as _fbthrift_python_mutable_containers
{{/program:generate_mutable_types}}
{{#program:include_namespaces}}
{{#has_types?}}

import {{included_module_path}}.{{> types/types_import_path}} as {{included_module_mangle}}__{{> types/types_import_path}}
{{/has_types?}}
{{/program:include_namespaces}}
{{#program:adapter_type_hint_modules}}
import {{module_path}}
{{/program:adapter_type_hint_modules}}
{{> types/import_enums}}
{{#program:structs}}


@_typing.final
class {{> structs/unadapted_name}}({{!
        }}{{#struct:union?}}{{> types/union_base }}{{/struct:union?}}{{!
        }}{{^struct:union?}}{{!
        }}{{#struct:exception?}}{{> types/exception_base }}{{/struct:exception?}}{{!
        }}{{^struct:exception?}}{{> types/struct_base }}{{/struct:exception?}}{{!
        }}{{/struct:union?}}{{!
        }}{{#program:enable_abstract_types?}}{{!
        }}, _fbthrift_python_abstract_types.{{> structs/unadapted_name}}{{!
        }}{{/program:enable_abstract_types?}}{{!
        }}):
    {{#program:generate_immutable_types}}{{!
    }}{{#struct:fields_ordered_by_id}}
    {{field:py_name}}: _typing.Final[{{> fields/field_type_pyi}}] = ...
    {{/struct:fields_ordered_by_id}}{{!
    }}{{/program:generate_immutable_types}}{{!
    }}{{#program:generate_mutable_types}}{{!
    }}{{#struct:fields_ordered_by_id}}{{!
    }}
    @property
    def {{field:py_name}}(self) -> {{> fields/field_type_pyi}}: ...
    @{{field:py_name}}.setter
    def {{field:py_name}}(self, value: {{> fields/field_type_pyi}}{{> types/add_wrapper_if_container}}) -> None: ...

    {{/struct:fields_ordered_by_id}}{{!
    }}{{/program:generate_mutable_types}}
    def __init__(
        self,{{#struct:fields?}} *{{/struct:fields?}}{{!
        }}{{#struct:fields_ordered_by_id}}{{> types/init_and_call_arg_types}}{{/struct:fields_ordered_by_id}}
    ) -> None: ...

    {{#struct:plain?}}
    def __call__(
        self,{{#struct:fields?}} *{{/struct:fields?}}{{!
        }}{{#struct:fields_ordered_by_id}}{{> types/init_and_call_arg_types}}{{/struct:fields_ordered_by_id}}
    ) -> _typing.Self: ...
    {{/struct:plain?}}
    {{#struct:union?}}

{{#program:generate_immutable_types}}
    class Type(enum.Enum):
        EMPTY: {{> structs/unadapted_name}}.Type = ...
    {{#struct:fields_ordered_by_id}}
        {{field:py_name}}: {{> structs/unadapted_name}}.Type = ...
    {{/struct:fields_ordered_by_id}}
{{/program:generate_immutable_types}}

{{> structs/maybe_union_field_and_value}}

{{#program:generate_immutable_types}}
    @classmethod
    def fromValue(cls, value: {{> types/field_value_pep484_union_type}}) -> {{> structs/unadapted_name}}: ...
    value: _typing.Final[{{> types/field_value_pep484_union_type}}]
    type: _typing.Final[Type]
    def get_type(self) -> Type: ...
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
    def get_type(self) -> FbThriftUnionFieldEnum: ...
{{/program:generate_mutable_types}}
    {{/struct:union?}}
    {{^struct:union?}}
    def __iter__(self) -> {{> types/iter_return_type}}: ...
    {{/struct:union?}}
    {{#struct:legacy_api?}}
{{#program:generate_immutable_types}}
    def _to_python(self) -> _typing.Self: ...
    def _to_mutable_python(self) -> "{{program:module_path}}.thrift_mutable_types.{{> structs/unadapted_name}}": ...  # type: ignore
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
    def _to_python(self) -> "{{program:module_path}}.thrift_types.{{> structs/unadapted_name}}": ...  # type: ignore
    def _to_mutable_python(self) -> _typing.Self: ...
{{/program:generate_mutable_types}}
    def _to_py3(self) -> "{{program:module_path}}.types.{{> structs/unadapted_name}}": ...  # type: ignore
    def _to_py_deprecated(self) -> "{{program:py_deprecated_module_path}}.ttypes.{{> structs/unadapted_name}}": ...  # type: ignore
    {{/struct:legacy_api?}}
{{#struct:has_adapter?}}
{{struct:py_name}} = {{adapter:type_hint}}{{#adapter:is_generic?}}[{{> structs/unadapted_name}}]{{/adapter:is_generic?}}
{{/struct:has_adapter?}}
{{> private/alias_prefix}}{{struct:py_name}} = {{struct:py_name}}{{!
}}{{/program:structs}}
{{#program:constants?}}

{{#program:constants}}

{{#constant:has_adapter?}}_fbthrift_unadapted_{{/constant:has_adapter?}}{{constant:name}}: {{#constant:type}}{{!
    }}{{> types/constant_pep484_type}}{{!
}}{{/constant:type}} = ...
{{#constant:has_adapter?}}
{{constant:name}}: {{constant:adapter_type_hint}} = ...
{{/constant:has_adapter?}}
{{/program:constants}}
{{/program:constants?}}
{{#program:typedefs?}}

{{#program:typedefs}}
{{typedef:name}} = {{#typedef:has_adapter?}}{{!
    }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#typedef:type}}{{> types/typedef_pep484_type}}{{/typedef:type}}]{{/adapter:is_generic?}}{{!
}}{{/typedef:has_adapter?}}{{!
}}{{^typedef:has_adapter?}}{{!
    }}{{#typedef:type}}{{> types/typedef_pep484_type}}{{/typedef:type}}{{!
}}{{/typedef:has_adapter?}}
{{/program:typedefs}}
{{/program:typedefs?}}
{{#program:services?}}
{{#program:services}}
{{> types/service_arg_types_pyi}}
{{#service:interactions}}
{{> types/service_arg_types_pyi}}
{{/service:interactions}}
{{/program:services}}
{{/program:services?}}
